<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>智能订餐</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/style.css">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/layer.css">
</head>
<body>
<div class="wraper">
    <div class="min-height">
        <div class="header font-white ">
            <a href="javascript:history.go(-1)" class="iconfont icon-left font-white back"></a>
            <div class="font-16 text-center">用餐详情</div>

        </div>
        <div class="choose">
            <form action="/Base/Inforschool/order" method="post" id='frm'>
                <div class="search flex_between">
                    <div class="flex_between  font-green font-12 search_all">
                        <div class="all_text ">全部</div>
                        <div class="iconfont icon-jiantou font-12"></div>
                    </div>
                    <input class="search_input flex_1 font-12 padding-0-0" type="text" name="ycname"
                           placeholder="请输入关键字" value="{BEESCRM:$tureycname}">
                    <input type="hidden" value="{BEESCRM:$timePID}" name="PID" class="hide js_submit">
                    <input type="hidden" value="{BEESCRM:$ID}" name="ID" class="hide js_submit">
                    <input type="hidden" value="{BEESCRM:$finish}" name="finish" class="hide js_submit">
                    <input type="hidden" value="{BEESCRM:$start}" name="start" class="hide js_submit">
                    <input type="hidden" value="{BEESCRM:$dctype}" name="condition" class="hide js_submit">
                    <input type="hidden" value="{BEESCRM:$or_id}" name="or_id" class="hide js_submit">
                    <input type="hidden" value="1" name="ceshi" class="hide js_submit">
                    <input type="submit" value="查找" class="hide js_submit">
                    <div class="iconfont icon-sousuo font-white text-center"></div>
                </div>
                <!--   select div 在接待来宾页面中不显示，因为只有来宾 没有别的用户-->
                <!--                 <div class="select select2 font-white text-center font-12 hide">
                                    <div class="select_list font-green">全部</div>
                                    <div class="select_list">教职工</div>
                                    <div class="select_list">学生</div>
                                    <div class="triangle"></div>
                                </div> -->
            </form>

        </div>
        <div class="clearfix">
            <form action="/Base/Inforschool/ordercheck" method="post">

                <div class="date pull-left font-12">
                    <volist name="numtime" id="v">
                        <div class="boxs  text-center  border time" data-time=" {BEESCRM:$v['2']}">
                            {BEESCRM:$v['2']}
                            <input type="hidden" name="time{BEESCRM:$vo[0]}" value="{BEESCRM:$time[0]}">

                        </div>
                    </volist>
                </div>

                <div class="right pull-left bg_white">
                    <volist name="allnum" id="v">
                        <div class="js_right padding-12 hide">
                            <volist name="v['2'].child" id="val">
                                <div class="boxs border padding-0">
                                    <div class="number_of_people border-left font-12 time"
                                         data-id="{BEESCRM:$val['ycuser_id']}">
                                        {BEESCRM:$val['yname']}
                                    </div>
                                    <div class="flex_between font-gray2 js_choose marginb-10">
                                        <div class="name width-40 js_lunch">
                                            <span class="iconfont icon-xuanze checkbox"></span>
                                            <span class="font-gray1">中餐</span>
                                        </div>
                                        <div class="width-60 choose js_click_select flex_between"
                                             data-id="{BEESCRM:$val['utype']}" data-tid="{BEESCRM:$val['ftype']}">
                                            <div class="combo_name" data-fname="{BEESCRM:$val['mfood'][0]['fname']}">
                                                {BEESCRM:$val['mfood'][0]['fname']}
                                            </div>
                                            <input type="hidden" name="food_id{BEESCRM:$val['mfood']['food_id']}"
                                                   value="{BEESCRM:$val['mfood']['food_id']}">
                                            <div class="iconfont icon-xiala"></div>
                                            <div class="select text-center hide">
                                                <volist name="food1" id="fval">
                                                    <div class="select_list select_list1 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                                <volist name="food2" id="fval">
                                                    <div class="select_list select_list2 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                                <volist name="food3" id="fval">
                                                    <div class="select_list select_list3 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                                <volist name="food4" id="fval">
                                                    <div class="select_list select_list4 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                            </div>
                                            <div class="triangle hide"></div>
                                        </div>
                                    </div>
                                    <div class="flex_between font-gray2 js_choose marginb-10">
                                        <div class="name width-40 js_dinner">
                                            <span class="iconfont icon-xuanze checkbox "></span>
                                            <span class="font-gray1">晚餐</span>
                                        </div>
                                        <div class="width-60 choose js_click_select flex_between "
                                             data-id="{BEESCRM:$val['utype']}" data-tid="{BEESCRM:$val['ftype']}">
                                            <div class="combo_name" data-fname="{BEESCRM:$val['nfood']['fname']}">
                                                {BEESCRM:$val['nfood'][0]['fname']}
                                            </div>
                                            <input type="hidden" name="food_id"
                                                   value="{BEESCRM:$val['nfood']['food_id']}">
                                            <div class="iconfont icon-xiala"></div>
                                            <div class="select text-center hide">
                                                <volist name="food1" id="fval">
                                                    <div class="select_list select_list1 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                                <volist name="food2" id="fval">
                                                    <div class="select_list select_list2 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                                <volist name="food3" id="fval">
                                                    <div class="select_list select_list3 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                                <volist name="food4" id="fval">
                                                    <div class="select_list select_list4 hide"
                                                         data-id="{BEESCRM:$fval['food_id']}">
                                                        {BEESCRM:$fval['fname']}
                                                    </div>
                                                </volist>
                                            </div>
                                            <div class="triangle hide"></div>
                                        </div>
                                    </div>
                                </div>
                            </volist>
                        </div>
                    </volist>
                </div>
                <input type="hidden" id="dctype" value="{BEESCRM:$dctype}">
                <!--    <input type="text" id="timeID" value="{BEESCRM:$ID}">
                    <input type="text" id="timePID" value="{BEESCRM:$timePID}">-->
                <input type="hidden" name="or_id" id="or_id" value="{BEESCRM:$or_id}">
                <!-- <input type="submit" value="下一步"> -->
            </form>
        </div>
    </div>
    <div class="bottom_btn flex_between text-center">
        <div class="bottom_hint">
            已预订中餐<span class="lunch_num">{BEESCRM:$mcount}</span>份，晚餐<span class="dinner_num">{BEESCRM:$ncount}</span>份
        </div>
        <a href="#" class="btn_account" id="reg">去结算</a>
    </div>
    <!--     <div class="pop-box font-gray1 hide">
            <div class="bg_white padding-12">
                <div class="boxs border padding-0">
                    2017-01-01 <span class="font-green">吴大鹏</span> 学生
                </div>
                <div class="boxs border padding-0">
                    2017-01-01 <span class="font-green">吴大鹏</span> 学生
                </div>
                <div class="boxs border padding-0">
                    2017-01-01 <span class="font-green">吴大鹏</span> 教职工
                </div>
            </div>
        </div> -->

</div>
</body>
<script src="/assets/base/Inforschool/js/jquery-2.1.0.min.js"></script>
<script src="/assets/base/Inforschool/js/layer.js"></script>
<script src="/assets/base/Inforschool/js/public.js"></script>
<script>
    var height = $(window).height();
    $('.wraper').css('minHeight', height);
    var btn_height = $('.bottom_btn').innerHeight();
    $('.min-height').css('height', height - btn_height);
    var header_height = $('.header').innerHeight();
    var search_height = $('.search').outerHeight(true);

    $('.pop-box').css('height', height - header_height - search_height);

    $('.right').css('minHeight',height-header_height-search_height-btn_height);

    $('.search_input').click(function () {
        $('.pop-box').removeClass('hide');
    });
    $('.icon-sousuo').click(function () {
        $('.pop-box').addClass('hide');
    });


    $('.js_click_select').click(function () {
        var $this = $(this).siblings('.name').find('.checkbox');
        if ($this.hasClass('icon-xuanze')) {
            $(this).children('.select').toggleClass('hide');
            $(this).children('.triangle').toggleClass('hide');
            $(this).parents('.js_choose').siblings().find('.select').addClass('hide');
            $(this).parents('.js_choose').siblings().find('.triangle').addClass('hide');
            $(this).parents('.boxs').siblings().find('.select').addClass('hide');
            $(this).parents('.boxs').siblings().find('.triangle').addClass('hide');
        }

        //
        var id = $(this).data('id');
        var id2 = $(this).data('tid');
        if (id == 1) {
            $(this).find('.select_list1').removeClass('hide');
        }
        else if (id == 2) {
            $(this).find('.select_list2').removeClass('hide');
        }
        else if (id == 3 && id2 == 2) {
            $(this).find('.select_list3').removeClass('hide');
        }
        else if (id == 3 && id2 == 3) {
            $(this).find('.select_list4').removeClass('hide');
        }
    });
    $(".select").on('click', '.select_list', function () {
        var txt = $(this).html();
        $(this).addClass('font-green').siblings().removeClass('font-green');
        $(this).parents(".select").siblings('.combo_name').text(txt);
        $(this).parents('.select').siblings().find('.all_text').text(txt);
        var ID=$.trim($(this).data('name'));
        $('#js_id').val(ID);
    });
    $(".select2").on('click', '.select_list', function () {
        $(this).parents('.select').addClass('hide');

    });
    $('.js_choose').on('click', '.name', function () {
        var $this = $(this).find('.checkbox');
        if ($this.hasClass('icon-xuanze')) {
            $this.removeClass('icon-xuanze').addClass('icon-xuanze1');
            $(this).siblings().find('.select').addClass('hide');
            $(this).siblings().find('.triangle').addClass('hide');
            $(this).parents('.js_choose').find('.combo_name').addClass('font-transparent');
        } else {
            $this.removeClass('icon-xuanze1').addClass('icon-xuanze');
            $(this).parents('.js_choose').find('.combo_name').removeClass('font-transparent');
        }
    });
    $('.date').on('click', '.boxs', function () {
        var idx=$(this).index();
        $('.right').find('.js_right').eq(idx).removeClass('hide').siblings().addClass('hide');
        $(this).addClass('bg_white js_visite').siblings().removeClass('bg_white js_visite');
    });

    $('.search').on('click', '.search_all', function () {
        $(this).parent('.search').siblings('.select2').toggleClass('hide');
    });

    $('.icon-sousuo').click(function () {
        $('.js_submit').click();
    })

    //点击提交
    $('#reg').click(function () {
        var or_id = $('#or_id').val();
        var dctype = $('#dctype').val();
        var lunch_num = $('.lunch_num').text();
        var dinner_num = $('.dinner_num').text();
        var data = {};
        data.or_id = or_id;
        data.dctype = dctype;
        $.ajax({
            'url': "/base/Inforschool/orderCheck",
            'data': data,
            'dataType': 'json',
            'type': 'POST',
            success: function (data) {
                if (data.status == 'S') {
                    setTimeout("reload('" + data.url + "')", 2000);
                } else {
                    return false;
                }
            }
        })
    });

    function reload(url) {
        location.href = url;
    }

    $(function () {
        $(".date .time:first").addClass('bg_white js_visite');
        $(".right .js_right:first").removeClass('hide');
    });

    $('.js_choose').each(function () {
        var name=$.trim($(this).find('.combo_name').text());
        if (name==''){
            $(this).find(".name").children('.iconfont').removeClass('icon-xuanze').addClass('icon-xuanze1');
        }
    });

    $('.js_choose').on('click', '.choose', function () {
        var title = $(this);
        var taocan = $.trim($(this).siblings('.name ').text());
        var times = $('.js_visite').data('time');
        var title2 = $.trim($(this).find('.combo_name').data('fname'));
        var name_id = $.trim($(this).parents('.js_choose').siblings('.number_of_people').data('id'));
        title.bind('DOMNodeInserted', function (e) {
            var txt=$.trim($(e.target).text());
            var txt_id = $.trim($(this).find('.select').children('.font-green').data('id'));
            var this_name =  $.trim($(this).find('.select').children('.font-green').text());
            if (this_name !== title2) {
                console.log('套餐名：'+taocan+txt+'，套餐id：'+txt_id+'，姓名：'+name_id+'，时间：'+times);
                //alert('套餐名：'+taocan+txt+'，套餐id：'+txt_id+'，姓名：'+name_id+'，时间：'+times);
                var data = {};
                var or_id = $('#or_id').val();
                data.type = taocan;
                data.food_id = txt_id;
                data.food_name = txt;
                data.duser_id = name_id;
                data.time = times;
                data.or_id = or_id;
                $.ajax({
                        'url': "/base/Inforschool/editTaocan",
                        'data': data,
                        'dataType': 'json',
                        'type': 'POST',
                    }
                )
                /*
                 alert('套餐：'+taocan+txt_id+'，姓名：'+name+'，时间：'+times);*/
            }
        });
    })

    $('.js_choose').on('click','.name',function () {
        var $this=$(this).find('.checkbox');
        if($this.hasClass('icon-xuanze1')){

            var title = $(this).siblings('.choose');
            var taocan = $.trim(title.siblings('.name ').text());
            var times = $('.js_visite').data('time');
            var name_id = $.trim(title.parents('.js_choose').siblings('.number_of_people').data('id'));
            console.log('套餐名：' + taocan  + '，姓名id：' + name_id + '，时间：' + times);
            var data = {};
            var or_id = $('#or_id').val();
            data.type = taocan;
            data.food_name = taocan;
            data.duser_id = name_id;
            data.time = times;
            data.or_id = or_id;
            $.ajax({
                    'url': "/base/Inforschool/delTaocan",
                    'data': data,
                    'dataType': 'json',
                    'type': 'POST',
                }
            )
        }
    })

    $('.js_choose').on('click','.js_lunch',function () {
        var lenght=$(this).parents('.right').find('.js_lunch').children('.icon-xuanze').length;
        $('.lunch_num').text(lenght);
    })
    $('.js_choose').on('click','.js_dinner',function () {
        var lenght=$(this).parents('.right').find('.js_dinner').children('.icon-xuanze').length;
        $('.dinner_num').text(lenght);
    })



</script>
</html>